package correct.day8;

import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        int n = scanner.nextInt();

        char[][] arr = new char[m+1][n+1];
        for (int i = 1; i <= m; i++) {
            String s = scanner.next();
            for (int j = 1; j <= n; j++) {
                arr[i][j] = s.charAt(j-1);
            }
        }

        int[][] dp = new int[m + 1][n + 1];
        for(int i = 1; i <= m; i++)
        {
            for(int j = 1; j <= n; j++)
            {
                int t = 0;
                if(arr[i][j] == 'l')
                    t = 4;
                else if(arr[i][j] == 'o')
                    t = 3;
                else if(arr[i][j] == 'v')
                    t = 2;
                else if(arr[i][j] == 'e')
                    t = 1;

                dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]) + t;
            }
        }

        System.out.println(dp[m][n]);
    }
}
